<?xml version="1.0" encoding="UTF-8" ?>
<!--
    page description : 근태관리 - 관리자 - 사원관리 화면 - 사원등록/수정 (pop_up)
    author      : Yang D
    date        : 2009-02-04
    file name   : emp_mgr_reg_auth_p.jsp
-->
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<jsp:directive.page import="attend.com.CodeMetrix"/>
<%@ taglib prefix="s" uri="/struts-tags" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<s:head theme="ajax"/>
	<link rel="stylesheet" type="text/css" href="/inc/css/common.css" />
	<script src="inc/js/common.js"></script>
	
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
	<title>사원관리-권한부여-</title>
	<script type="text/javascript">
		
		function fnc_auto_add_tr() {
		
			var tr = document.createElement("tr");
			var td = document.createElement("td");
			
			target.appendChild(tr);
			target.appendChild(td);
		    
		}
		
		/**
	    *그룹선택이 변경될 경우에 팀과 사원  list를 변경한다.
	    */
	    function selectChange(f) {
	    	
	    	if (f == "team") return false;
	    	
	    	var idx = f.group_no.selectedIndex;
	    	var opt = f.group_no.options[idx];
	    	
	    	f.sgroup.value = opt.value;
	    	
			dojo.event.topic.publish("show_team");
			return false;
		}
		
		function isValidate(f) {
			//validation
			if (typeof f.group_no == undefined) {
				alert("<s:text name="alert.message.notSave" />");
				return false;
			}
			
			var idx = f.group_no.selectedIndex;
	    	var opt = f.group_no.options[idx];
	    		
	    	var tidx = f.steam.selectedIndex;
	    	var topt = f.steam.options[tidx];
	    	
	    	if (idx != 0 && tidx == 0) {
	    		alert("권한을 추가할 팀을 \n\n올바르게 선택하여 주시기 바랍니다.");
	    		f.group_no.selectedIndex = 0;
	    		return false;
	    	}
	    	
	    	if (typeof f.a_team_no.length == "undefined") {
	    		if (opt.value.length == 0) {
	    			alert("<s:text name="alert.message.selectGroupname" />");
		    		f.group_no.focus();
		    		return false;
	    		}
	    		
	    		if (topt.value == "ALL") {
	    			alert("<s:text name="alert.message.selectTeamName" />");
		    		f.steam.focus();
		    		return false;
	    		}
	    		
	    		//팀코드를 넘긴다.
    			f.a_team_no.value = topt.value;
    		
	    	} else {
	    		f.a_team_no[f.a_team_no.length - 1].value = topt.value;	//팀코드를 히든으로 전달한다.
	    	}

			return true;
		}
		
		//저장버튼
		function fnc_submit(f) {
			if(isValidate(f)) {
				
				if (!confirm("<s:text name="alert.message.questionSave" />")) {
					return false;
				} 
				
				f.action = "saveEmpDept_p.action";
		    	f.submit();
			}
			
			return false;
		}

		window.onload = function(){

	         if((parseInt(document.getElementById("popup_550se_bg").offsetHeight) - parseInt(window.document.body.clientHeight)) > 20 ){

	                 window.document.body.scroll = "auto";
	                 window.resizeBy(0,0);
	         }
	         
			if ('<s:property value="msg" />' == "<%= CodeMetrix.DUPLICATE%>") {

				alert("<s:text name="alert.message.duplicate" />");
				window.close();
				return false;
			}
			document.getElementById("img_save").focus();

	    }

	</script>
</head>
<body >
	<div id="popup_550se_top" ></div>
    <div id="popup_550se_bg">
        <s:form name="frm" id="frm" method="post" theme="simple" onsubmit="return fnc_submit(this)">
        	<s:hidden name="msg" 		/>				<!-- 저장 메시지 출력 -->
        	<s:hidden name="crud_type"	/>
        	<input type="hidden" name="h_emp_no" id="h_emp_no" value="<s:property value="emp_no" />" />
			<table class="pop550se_Tbl" border="1">
				<tr>
					<th>순번</th><th>성명</th><th>사업그룹명</th><th>팀명</th><th>권한여부</th>
				</tr>
				<s:iterator value="list" id="iter" status="row">
				<tr>
			        <td><s:property value="%{#row.index + 1}"/><s:hidden name="auth_seq" /><input type="hidden" name="a_seq" value="<s:property value="auth_seq"/>" /></td>
			        <td><s:property value="emp_nm"/><input 		type="hidden" name="a_emp_no" 	value="<s:property value="emp_no"/>" /></td>
			        <td><s:property value="group_nm"/><input	type="hidden" name="a_group_no" value="<s:property value="group_no"/>" /></td>
			        <td><s:property value="team_nm"/><s:hidden name="team_no"/><input type="hidden" name="a_team_no" value="<s:property value="team_no"/>" /></td>
			        <td><s:select id="approv_yn" name="approv_yn" list="#{'Y':'Y' , 'N':'N'}" cssClass="combobox100se" /></td>
			    </tr>
				</s:iterator>
				<tr>
					<td><input type="hidden" name="a_emp_no" value="<s:property value="emp_info.emp_no"/>" /></td>
					<td><s:property value="emp_info.emp_nm"/><s:hidden name="emp_no"/></td>
					<td>
						<s:select list="listGroup" name="group_no" id="group_no" headerKey="" headerValue="::선택::" listKey="group_no" listValue="group_nm" onchange="return selectChange(this.form)"/>
						<s:hidden id="sgroup" name="sgroup" value="%{group_no}" />
					</td>
					<td>
			        	<s:url id="team_url" action="com_select_team_auth_dept_s" />
						<s:div showLoadingText="false" id="team_div" href="%{team_url}" theme="ajax" listenTopics="show_team" formId="frm"/>
						<input type="hidden" name="a_team_no" />
			        </td>
			        <td><s:select id="approv_yn" name="approv_yn" list="#{'Y':'Y' , 'N':'N'}" cssClass="combobox100se" /></td>					
				</tr>
			</table>
			<div id="popup_btn"><s:submit type="image" name="img_save" id="img_save" src="/images/btn_save.gif" value="저장" /></div>
			<br>
		    <!---------------Bottom : STR----------->
			<div id="popup_550se_bottom"><img src="/images/pop_btn_close.gif"  onclick="window.close();" style="cursor: pointer;"/></div>
			<!---------------Bottom : END----------->
        </s:form>
        
    </div>
    
</body>
</html>